﻿using SmartSpace.Orgs;
using SmartSpace.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SmartSpace.WebApp.Modules.Orgs.Pages
{
    public partial class Employee_Detail : SsTemplatePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String empyloyeeId = Request.QueryString["empyloyeeId"] ?? String.Empty;
            if (!IsPostBack)
            {
                BindEmployee(empyloyeeId);
            }
        }

        public void BindEmployee(string id)
        {
            if (id == "")
            {
                return;
            }
            OrgsService service = new OrgsService();
            Employee emloyee = service.GetEmployee(new Guid(id)).Data;

            this.txt_Code.Text = emloyee.Code;
            this.txt_Account.Text = emloyee.Account;
            this.txt_NameCN.Text = emloyee.NameCN;
            this.txt_NameEN.Text = emloyee.NameEN;
            this.txt_Email.Text = emloyee.Email;
            this.txt_Phone.Text = emloyee.Phone;
            this.txt_Sex.Text = emloyee.Sex.ToString();
            this.txt_IdCardNo.Text = emloyee.IdCardNo;
            this.txt_Birthday.Text = emloyee.Birthday.ToString();
        }

        protected void link_back_Click(object sender, EventArgs e)
        {
            string tag = Request.QueryString["tag"] ?? string.Empty;
            if (tag =="orglist")
            {
                string nodeId = Request.QueryString["nodeId"] ?? string.Empty;
                Response.Redirect("Org-Employee-List.aspx?nodeId=" + nodeId);
            }
            if (tag=="employeelist")
            {
                Response.Redirect("Employee-List.aspx");
            }
        }
    }
}